//
//  Model_Base.h
//  Qianbao
//
//  Created by zhangtie on 13-4-3.
//  Copyright (c) 2013年 qianwang365. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AppDelegate.h"

#ifndef _ALLOC_OBJ_WITHFRAME_
#define _ALLOC_OBJ_WITHFRAME_(obj_class, _frame) \
        [[obj_class alloc]initWithFrame:_frame]
#endif

#ifndef _ALLOC_OBJ_
#define _ALLOC_OBJ_(obj_class) \
        [[obj_class alloc]init]
#endif

#ifndef FONT_TITLE
#define FONT_TITLE(X) [UIFont systemFontOfSize:X]
#endif

#ifndef SIMPLE_SAFERELEASE
#define SIMPLE_SAFERELEASE(x)\
        if(x)\
        {\
            [x release];\
        }
#endif

#ifndef REMOVEALLSUBVIEW
#define REMOVEALLSUBVIEW(__desView__)\
        if(__desView__)\
        {\
            NSArray *subViews = [__desView__ subviews];\
            if([subViews count] != 0)\
            {\
                [subViews makeObjectsPerformSelector:@selector(removeFromSuperview)];\
            }\
        }
#endif

#ifndef REMOVESUBVIEW
#define REMOVESUBVIEW(__superView, __tag)\
        {\
                UIView *__view_sub = [__superView viewWithTag:__tag];\
                if(__view_sub)\
                {\
                    [__view_sub removeFromSuperview];\
                }\
        }
#endif

#ifndef _SETDEFAULT_VIEW_STYLE
#define _SETDEFAULT_VIEW_STYLE(__view, __borderColor, __radius)\
        if([__view isKindOfClass:[UIView class]])\
        {\
            __view.layer.cornerRadius  = __radius;\
            __view.layer.borderWidth   = 1.0f;\
            __view.layer.masksToBounds = YES;\
            __view.layer.borderColor   = __borderColor.CGColor;\
        }
#endif

//动画声明
#define _ANIMATIONS_INIT_BEGIN_(time)       [UIView beginAnimations:@"Curl" context:nil];\
                                            [UIView setAnimationDuration:time]; \
                                            [UIView setAnimationDelegate:self];
//动画结束语句
#define _ANIMATIONS_INIT_END_               [UIView commitAnimations];

#define FONT_DEFAULT  FONT_TITLE(12)

#define COLOR_DEFAULT_SELECTED      [UIColor orangeColor]
#define COLOR_DEFAULT_NORMAL        [UIColor lightGrayColor]
#define COLOR_DEFAULT_TEXTNORMAL    [UIColor blackColor]
#define COLOR_DEFAULT_TEXTSELECTED  [UIColor whiteColor]

#define _AVALIBEL_HEIGHT_(x)    \
        floorf(x/460.0*(_DEVICEHEIGHT_ - 20))

#define _DEVICEHEIGHT_  [UIScreen mainScreen].bounds.size.height

#define _VIEW_AVALIABLE_HEIGHT (_DEVICEHEIGHT_ - 44 - 20)



#define IMAGE_NORESULT  IMGNAMED(@"bg_no_result.png")


/**************************通知名****************************/
#define NOTIFY_DATASOURCE   @"dataSource"
/**************************通知名****************************/

typedef  enum _DIRECTION_MOVE
{
    DIRECTION_MOVE_UP = 0,
    DIRECTION_MOVE_DOWN = 1,
}DIRECTION_MOVE;

//数据类型
typedef enum _DATA_TYPE
{
    DATA_TYPE_VALUE      = 0,
    DATA_TYPE_DICTIONARY = 1,
}DATA_TYPE;

//布局类型
typedef enum _LAYOUT_TYPE
{
    LAYOUT_TYPE_DEFAULT     = 0,    //默认布局方式
    LAYOUT_TYPE_SIGNIMAGE   = 1,    //用带箭头的风格
    //可以根据自己需要扩充对应的方式....
}LAYOUT_TYPE;

typedef enum _TABITEM_STATE
{
    TABITEM_STATE_NORMAL   = 0,
    TABITEM_STATE_SELECTED = 1,
}TABITEM_STATE;


@interface DataItem : NSObject
{
@protected
    DATA_TYPE   _data_type;      //default is DATE_TYPE_VALUE
    
    id          _item_data;
}

@property(nonatomic, assign)DATA_TYPE data_type;
@property(nonatomic, retain)id item_data;
- (id)initWithData:(id)data;
+ (id)dataItemWithData:(id)data;
@end